package com.twu.biblioteca.model.item.movies;

import com.twu.biblioteca.model.item.movies.exceptions.InvalidRatingException;

/**
 * Created with IntelliJ IDEA.
 * User: cschlumb
 * Date: 09/08/2013
 * Time: 10:45
 * To change this template use File | Settings | File Templates.
 */
public class Rating {

    private final static int minumum = 1;
    private final static int maximum = 10;

    private Integer rating;

    private Rating(Integer rating) {
        this.rating = rating;
    }

    public static Rating rating(int rating){
        if (rating < minumum || rating > maximum)
            throw new InvalidRatingException();

        return new Rating(rating);
    }

    public static Rating unrated(){
        return new Rating(null);
    }

    public Integer getRating() {
        return rating;
    }

    public boolean isRated(){
        return rating != null;
    }
}
